// 菜单栏 https://www.electronjs.org/zh/docs/latest/api/menu-item#%E8%8F%9C%E5%8D%95%E9%A1%B9
import type { MenuItem, MenuItemConstructorOptions } from "electron";
import { Menu } from "electron";

/**
 * 菜单定义
 *
 * @param isDev 是否开发模式
 * @returns
 */
export const createAppMenu = (isDev: boolean): void => {
  const template: (MenuItemConstructorOptions | MenuItem)[] = [];
  if (isDev) {
    template.push({
      label: "DEBUG: ON",
      submenu: [
        { label: "关于", role: "about" },
        { label: "开发者工具", role: "toggleDevTools" },
        { label: "强制刷新", role: "forceReload" },
        { label: "退出", role: "quit" }
      ]
    });
  }
  const appMenu = Menu.buildFromTemplate(template);
  Menu.setApplicationMenu(appMenu);
};
